package com.kaishengit.service;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.kaishengit.dao.TaskDao;
import com.kaishengit.dao.TaskTypeDao;
import com.kaishengit.pojo.Task;
import com.kaishengit.pojo.TaskType;
import com.kaishengit.pojo.User;

@Transactional
public class TaskService {
	private TaskDao taskDao;
	private TaskTypeDao taskTypeDao;
	public TaskTypeDao getTaskTypeDao() {
		return taskTypeDao;
	}


	public void setTaskTypeDao(TaskTypeDao taskTypeDao) {
		this.taskTypeDao = taskTypeDao;
	}


	public TaskDao getTaskDao() {
		return taskDao;
	}


	private User user;
	
	
	public void save(Task task,User user,TaskType tasktype){
		
			task.setUser(user);
			task.setTaskType(tasktype);
			System.out.println(task.getTaskType()+"ap.......................");
			System.out.println(task.isAlls()+"ap.......................");
		if(!task.isComplete()){
			task.setComplete(false);
			
		}else{
			task.setComplete(true);
		}
		if(!task.isAlls()){
			task.setAlls(false);
		}else{
			task.setAlls(true);
		}
		taskDao.save(task);
	}
	public List<TaskType> tasktypeList(){
		return taskTypeDao.findAll();
	}
	
	
	public void setTaskDao(TaskDao taskDao) {
		this.taskDao = taskDao;
	}


	public List<Task> findAll() {
		return taskDao.findAll();
	}


	public User getUser() {
		return user;
	}


	public void setUser(User user) {
		this.user = user;
	}
	

}
